package com.lej.dataservice.club.http.base

import com.lej.core.utils.extention.toJson
import com.lej.dataservice.club.http.interceptor.ParamsInterceptor
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.toRequestBody

fun getBody(vararg params: Pair<String, Any>) = HashMap<String, Any>().apply {
    ParamsInterceptor.getCommParams().forEach {//添加公共参数
        put(it.key, it.value)
    }
    params.forEach { put(it.first, it.second) }
}.toJson().toRequestBody("application/json; charset=utf-8".toMediaTypeOrNull())

fun Any.toBody() = toJson().toRequestBody("application/json; charset=utf-8".toMediaTypeOrNull())
